home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2011 April / ME_2011_04.iso / [Video-Tutorial] / start.swf / scripts / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2010-10-14  |  17.2 KB  |  622 lines

  1. if(_global.$tweenManager == undefined)
  2. {
  3.    _global.$tweenManager = new zigo.tweenManager();
  4. }
  5. else
  6. {
  7.    _global.$tweenManager.cleanUp();
  8.    _global.$tweenManager.init();
  9. }
  10. com.robertpenner.easing.Back;
  11. com.robertpenner.easing.Bounce;
  12. com.robertpenner.easing.Circ;
  13. com.robertpenner.easing.Cubic;
  14. com.robertpenner.easing.Elastic;
  15. com.robertpenner.easing.Expo;
  16. com.robertpenner.easing.Linear;
  17. com.robertpenner.easing.Quad;
  18. com.robertpenner.easing.Quart;
  19. com.robertpenner.easing.Quint;
  20. com.robertpenner.easing.Sine;
  21. var Mp = MovieClip.prototype;
  22. Mp.addListener = function()
  23. {
  24.    if(!this._listeners)
  25.    {
  26.       AsBroadcaster.initialize(this);
  27.    }
  28.    this.addListener.apply(this,arguments);
  29. };
  30. ASSetPropFlags(Mp,"addListener",1,0);
  31. Mp.tween = function(props, pEnd, seconds, animType, delay, callback, extra1, extra2)
  32. {
  33.    if(_global.$tweenManager.isTweenLocked(this))
  34.    {
  35.       return undefined;
  36.    }
  37.    if(arguments.length < 2)
  38.    {
  39.       return undefined;
  40.    }
  41.    if(typeof props == "string")
  42.    {
  43.       if(props.indexOf(",") > -1)
  44.       {
  45.          props = props.split(" ").join("").split(",");
  46.       }
  47.       else
  48.       {
  49.          props = [props];
  50.       }
  51.    }
  52.    if(!(pEnd instanceof Array))
  53.    {
  54.       pEnd = [pEnd];
  55.       while(pEnd.length < props.length)
  56.       {
  57.          pEnd.push(pEnd[0]);
  58.       }
  59.    }
  60.    if(seconds == undefined)
  61.    {
  62.       seconds = 2;
  63.    }
  64.    else if(seconds < 0.01)
  65.    {
  66.       seconds = 0;
  67.    }
  68.    if(delay < 0.01 || delay == undefined)
  69.    {
  70.       delay = 0;
  71.    }
  72.    switch(typeof animType)
  73.    {
  74.       case "string":
  75.          animType = animType.toLowerCase();
  76.          if(animType == "linear")
  77.          {
  78.             var eqf = com.robertpenner.easing.Linear.easeNone;
  79.          }
  80.          else if(animType.indexOf("easeoutin") == 0)
  81.          {
  82.             var t = animType.substr(9);
  83.             t = t.charAt(0).toUpperCase() + t.substr(1);
  84.             var eqf = com.robertpenner.easing[t].easeOutIn;
  85.          }
  86.          else if(animType.indexOf("easeinout") == 0)
  87.          {
  88.             var t = animType.substr(9);
  89.             t = t.charAt(0).toUpperCase() + t.substr(1);
  90.             var eqf = com.robertpenner.easing[t].easeInOut;
  91.          }
  92.          else if(animType.indexOf("easein") == 0)
  93.          {
  94.             var t = animType.substr(6);
  95.             t = t.charAt(0).toUpperCase() + t.substr(1);
  96.             var eqf = com.robertpenner.easing[t].easeIn;
  97.          }
  98.          else if(animType.indexOf("easeout") == 0)
  99.          {
  100.             var t = animType.substr(7);
  101.             t = t.charAt(0).toUpperCase() + t.substr(1);
  102.             var eqf = com.robertpenner.easing[t].easeOut;
  103.          }
  104.          if(eqf == undefined)
  105.          {
  106.             var eqf = com.robertpenner.easing.Expo.easeOut;
  107.          }
  108.          break;
  109.       case "function":
  110.          var eqf = animType;
  111.          break;
  112.       case "object":
  113.          if(animType.ease != undefined && animType.pts != undefined)
  114.          {
  115.             var eqf = animType.ease;
  116.             extra1 = animType.pts;
  117.          }
  118.          else
  119.          {
  120.             var eqf = com.robertpenner.easing.Expo.easeOut;
  121.          }
  122.          break;
  123.       default:
  124.          var eqf = com.robertpenner.easing.Expo.easeOut;
  125.    }
  126.    switch(typeof callback)
  127.    {
  128.       case "function":
  129.          callback = {func:callback,scope:this._parent};
  130.          break;
  131.       case "string":
  132.          var ilp;
  133.          var funcp;
  134.          var scope;
  135.          var args;
  136.          var a;
  137.          ilp = callback.indexOf("(");
  138.          funcp = callback.slice(0,ilp);
  139.          scope = eval(funcp.slice(0,funcp.lastIndexOf(".")));
  140.          func = eval(funcp);
  141.          args = callback.slice(ilp + 1,callback.lastIndexOf(")")).split(",");
  142.          var i = 0;
  143.          while(i < args.length)
  144.          {
  145.             a = eval(args[i]);
  146.             if(a != undefined)
  147.             {
  148.                args[i] = a;
  149.             }
  150.             i++;
  151.          }
  152.          callback = {func:func,scope:scope,args:args};
  153.    }
  154.    if(_global.$tweenManager.autoStop)
  155.    {
  156.       _global.$tweenManager.removeTween(this);
  157.    }
  158.    if(delay > 0)
  159.    {
  160.       _global.$tweenManager.addTweenWithDelay(delay,this,props,pEnd,seconds,eqf,callback,extra1,extra2);
  161.    }
  162.    else
  163.    {
  164.       _global.$tweenManager.addTween(this,props,pEnd,seconds,eqf,callback,extra1,extra2);
  165.    }
  166. };
  167. Mp.stopTween = function(props)
  168. {
  169.    if(typeof props == "string")
  170.    {
  171.       if(props.indexOf(",") > -1)
  172.       {
  173.          props = props.split(" ").join("").split(",");
  174.       }
  175.       else
  176.       {
  177.          props = [props];
  178.       }
  179.    }
  180.    _global.$tweenManager.removeTween(this,props);
  181. };
  182. Mp.isTweening = function(prop)
  183. {
  184.    return _global.$tweenManager.isTweening(this,prop);
  185. };
  186. Mp.getTweens = function()
  187. {
  188.    return _global.$tweenManager.getTweens(this);
  189. };
  190. Mp.lockTween = function()
  191. {
  192.    _global.$tweenManager.lockTween(this,true);
  193. };
  194. Mp.unlockTween = function()
  195. {
  196.    _global.$tweenManager.lockTween(this,false);
  197. };
  198. Mp.isTweenLocked = function()
  199. {
  200.    return _global.$tweenManager.isTweenLocked(this);
  201. };
  202. Mp.isTweenPaused = function(prop)
  203. {
  204.    return _global.$tweenManager.isTweenPaused(this,prop);
  205. };
  206. Mp.pauseTween = function(props)
  207. {
  208.    var _loc4_ = undefined;
  209.    if(props != undefined)
  210.    {
  211.       if(typeof props == "string")
  212.       {
  213.          if(props.indexOf(",") > -1)
  214.          {
  215.             props = props.split(" ").join("").split(",");
  216.          }
  217.          else
  218.          {
  219.             props = [props];
  220.          }
  221.       }
  222.       _loc4_ = {};
  223.       for(var _loc5_ in props)
  224.       {
  225.          _loc4_[props[_loc5_]] = true;
  226.       }
  227.    }
  228.    _global.$tweenManager.pauseTween(this,_loc4_);
  229. };
  230. Mp.unpauseTween = function(props)
  231. {
  232.    var _loc4_ = undefined;
  233.    if(props != undefined)
  234.    {
  235.       if(typeof props == "string")
  236.       {
  237.          if(props.indexOf(",") > -1)
  238.          {
  239.             props = props.split(" ").join("").split(",");
  240.          }
  241.          else
  242.          {
  243.             props = [props];
  244.          }
  245.       }
  246.       _loc4_ = {};
  247.       for(var _loc5_ in props)
  248.       {
  249.          _loc4_[props[_loc5_]] = true;
  250.       }
  251.    }
  252.    _global.$tweenManager.unpauseTween(this,_loc4_);
  253. };
  254. Mp.pauseAllTweens = function()
  255. {
  256.    _global.$tweenManager.pauseTween();
  257. };
  258. Mp.unpauseAllTweens = function()
  259. {
  260.    _global.$tweenManager.unpauseTween();
  261. };
  262. Mp.stopAllTweens = function()
  263. {
  264.    _global.$tweenManager.stopAll();
  265. };
  266. Mp.ffTween = function(props)
  267. {
  268.    var _loc4_ = undefined;
  269.    if(props != undefined)
  270.    {
  271.       if(typeof props == "string")
  272.       {
  273.          if(props.indexOf(",") > -1)
  274.          {
  275.             props = props.split(" ").join("").split(",");
  276.          }
  277.          else
  278.          {
  279.             props = [props];
  280.          }
  281.       }
  282.       _loc4_ = {};
  283.       for(var _loc5_ in props)
  284.       {
  285.          _loc4_[props[_loc5_]] = true;
  286.       }
  287.    }
  288.    _global.$tweenManager.ffTween(this,_loc4_);
  289. };
  290. Mp.rewTween = function(props)
  291. {
  292.    var _loc4_ = undefined;
  293.    if(props != undefined)
  294.    {
  295.       if(typeof props == "string")
  296.       {
  297.          if(props.indexOf(",") > -1)
  298.          {
  299.             props = props.split(" ").join("").split(",");
  300.          }
  301.          else
  302.          {
  303.             props = [props];
  304.          }
  305.       }
  306.       _loc4_ = {};
  307.       for(var _loc5_ in props)
  308.       {
  309.          _loc4_[props[_loc5_]] = true;
  310.       }
  311.    }
  312.    _global.$tweenManager.rewTween(this,_loc4_);
  313. };
  314. Mp.alphaTo = function(destAlpha, seconds, animType, delay, callback, extra1, extra2)
  315. {
  316.    this.tween(["_alpha"],[destAlpha],seconds,animType,delay,callback,extra1,extra2);
  317. };
  318. Mp.scaleTo = function(destScale, seconds, animType, delay, callback, extra1, extra2)
  319. {
  320.    this.tween(["_xscale","_yscale"],[destScale,destScale],seconds,animType,delay,callback,extra1,extra2);
  321. };
  322. Mp.sizeTo = function(destSize, seconds, animType, delay, callback, extra1, extra2)
  323. {
  324.    this.tween(["_width","_height"],[destSize,destSize],seconds,animType,delay,callback,extra1,extra2);
  325. };
  326. Mp.slideTo = function(destX, destY, seconds, animType, delay, callback, extra1, extra2)
  327. {
  328.    this.tween(["_x","_y"],[destX,destY],seconds,animType,delay,callback,extra1,extra2);
  329. };
  330. Mp.rotateTo = function(destRotation, seconds, animType, delay, callback, extra1, extra2)
  331. {
  332.    this.tween(["_rotation"],[destRotation],seconds,animType,delay,callback,extra1,extra2);
  333. };
  334. _global.getColorTransObj = function(type, amt, rgb)
  335. {
  336.    switch(type)
  337.    {
  338.       case "brightness":
  339.          var _loc4_ = 100 - Math.abs(amt);
  340.          var _loc6_ = 0;
  341.          if(amt > 0)
  342.          {
  343.             _loc6_ = 256 * (amt / 100);
  344.          }
  345.          return {ra:_loc4_,rb:_loc6_,ga:_loc4_,gb:_loc6_,ba:_loc4_,bb:_loc6_};
  346.       case "brightOffset":
  347.          _loc6_ = 256 * (amt / 100);
  348.          return {ra:100,rb:_loc6_,ga:100,gb:_loc6_,ba:100,bb:_loc6_};
  349.       case "contrast":
  350.          var _loc2_ = {};
  351.          var _loc0_ = null;
  352.          _loc2_.ba = _loc0_ = amt;
  353.          _loc2_.ga = _loc0_;
  354.          _loc2_.ra = _loc0_;
  355.          _loc2_.bb = _loc0_ = 128 - 1.28 * amt;
  356.          _loc2_.gb = _loc0_;
  357.          _loc2_.rb = _loc0_;
  358.          return _loc2_;
  359.       case "invertColor":
  360.          _loc2_ = {};
  361.          _loc2_.ba = _loc0_ = 100 - 2 * amt;
  362.          _loc2_.ga = _loc0_;
  363.          _loc2_.ra = _loc0_;
  364.          _loc2_.bb = _loc0_ = amt * 2.55;
  365.          _loc2_.gb = _loc0_;
  366.          _loc2_.rb = _loc0_;
  367.          return _loc2_;
  368.       case "tint":
  369.          if(rgb == undefined || rgb == null)
  370.          {
  371.             break;
  372.          }
  373.          var _loc8_ = rgb >> 16;
  374.          var _loc9_ = rgb >> 8 & 0xFF;
  375.          var _loc7_ = rgb & 0xFF;
  376.          var _loc5_ = amt / 100;
  377.          _loc2_ = {rb:_loc8_ * _loc5_,gb:_loc9_ * _loc5_,bb:_loc7_ * _loc5_};
  378.          _loc2_.ba = _loc0_ = 100 - amt;
  379.          _loc2_.ga = _loc0_;
  380.          _loc2_.ra = _loc0_;
  381.          return _loc2_;
  382.    }
  383.    return {rb:0,ra:100,gb:0,ga:100,bb:0,ba:100};
  384. };
  385. Mp.brightnessTo = function(bright, seconds, animType, delay, callback, extra1, extra2)
  386. {
  387.    this.tween(["_ct_"],[getColorTransObj("brightness",bright)],seconds,animType,delay,callback,extra1,extra2);
  388. };
  389. Mp.brightOffsetTo = function(percent, seconds, animType, delay, callback, extra1, extra2)
  390. {
  391.    this.tween(["_ct_"],[getColorTransObj("brightOffset",percent)],seconds,animType,delay,callback,extra1,extra2);
  392. };
  393. Mp.contrastTo = function(percent, seconds, animType, delay, callback, extra1, extra2)
  394. {
  395.    this.tween(["_ct_"],[getColorTransObj("contrast",percent)],seconds,animType,delay,callback,extra1,extra2);
  396. };
  397. Mp.colorTo = function(rgb, seconds, animType, delay, callback, extra1, extra2)
  398. {
  399.    this.tween(["_ct_"],[getColorTransObj("tint",100,rgb)],seconds,animType,delay,callback,extra1,extra2);
  400. };
  401. Mp.colorTransformTo = function(ra, rb, ga, gb, ba, bb, aa, ab, seconds, animType, delay, callback, extra1, extra2)
  402. {
  403.    var _loc2_ = {ra:ra,rb:rb,ga:ga,gb:gb,ba:ba,bb:bb,aa:aa,ab:ab};
  404.    this.tween(["_ct_"],[_loc2_],seconds,animType,delay,callback,extra1,extra2);
  405. };
  406. Mp.invertColorTo = function(percent, seconds, animType, delay, callback, extra1, extra2)
  407. {
  408.    this.tween(["_ct_"],[getColorTransObj("invertColor",percent)],seconds,animType,delay,callback,extra1,extra2);
  409. };
  410. Mp.tintTo = function(rgb, percent, seconds, animType, delay, callback, extra1, extra2)
  411. {
  412.    this.tween(["_ct_"],[getColorTransObj("tint",percent,rgb)],seconds,animType,delay,callback,extra1,extra2);
  413. };
  414. Mp.getFrame = function()
  415. {
  416.    return this._currentframe;
  417. };
  418. Mp.setFrame = function(fr)
  419. {
  420.    this.gotoAndStop(Math.round(fr));
  421. };
  422. Mp.addProperty("_frame",Mp.getFrame,Mp.setFrame);
  423. Mp.frameTo = function(endframe, duration, animType, delay, callback, extra1, extra2)
  424. {
  425.    if(endframe == undefined)
  426.    {
  427.       endframe = this._totalframes;
  428.    }
  429.    this.tween("_frame",endframe,duration,animType,delay,callback,extra1,extra2);
  430. };
  431. var TFP = TextField.prototype;
  432. if(!TFP.origAddListener)
  433. {
  434.    TFP.origAddListener = TFP.addListener;
  435.    ASSetPropFlags(TFP,"origAddListener",1,0);
  436.    TFP.addListener = function()
  437.    {
  438.       if(!this._listeners)
  439.       {
  440.          AsBroadcaster.initialize(this);
  441.       }
  442.       this.origAddListener.apply(this,arguments);
  443.    };
  444. }
  445. var $_$methods = ["tween","stopTween","isTweening","getTweens","lockTween","isTweenLocked","unlockTween","isTweenPaused","pauseTween","unpauseTween","pauseAllTweens","unpauseAllTweens","stopAllTweens","ffTween","rewTween","getFrame","setFrame","_frame","frameTo","alphaTo","brightnessTo","colorTo","colorTransformTo","invertColorTo","tintTo","scaleTo","sizeTo","slideTo","rotateTo","brightOffsetTo","contrastTo"];
  446. for(var $_$i in $_$methods)
  447. {
  448.    ASSetPropFlags(Mp,$_$methods[$_$i],1,0);
  449.    if($_$methods[$_$i].toLowerCase().indexOf("frame") == -1)
  450.    {
  451.       TFP[$_$methods[$_$i]] = Mp[$_$methods[$_$i]];
  452.       ASSetPropFlags(TFP,$_$methods[$_$i],1,0);
  453.    }
  454. }
  455. delete Mp;
  456. delete TFP;
  457. delete $_$methods;
  458. delete $_$i;
  459. TextField.prototype.typeWriter = function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  460. {
  461.    clearInterval(this.tw__interval);
  462.    var originalTxt = arg1;
  463.    this._visible = false;
  464.    if(this.html)
  465.    {
  466.       this.htmlText = arg1;
  467.    }
  468.    else
  469.    {
  470.       this.text = arg1;
  471.    }
  472.    if(arg4 == undefined || null)
  473.    {
  474.       arg4 = "";
  475.    }
  476.    var txt = this.text;
  477.    var txt_length = txt.length;
  478.    this.text = "";
  479.    if(this.autoSize == false || "none")
  480.    {
  481.       var last_visible_word = 0;
  482.       var last_visible_character = 0;
  483.       var txt_array = txt.split(" ");
  484.       var temp_string = "";
  485.       var i = 0;
  486.       while(i < txt_array.length)
  487.       {
  488.          temp_string += txt_array[i] + " ";
  489.          this.text = temp_string;
  490.          if(this.textHeight > this._height)
  491.          {
  492.             last_visible_character = temp_string.length;
  493.             last_visible_word = i - 1;
  494.             break;
  495.          }
  496.          i++;
  497.       }
  498.       if(last_visible_word == 0)
  499.       {
  500.          last_visible_character = txt_length;
  501.       }
  502.    }
  503.    else
  504.    {
  505.       last_visible_character = txt_length;
  506.    }
  507.    this.text = "";
  508.    this._visible = true;
  509.    txt_array = [];
  510.    var w = 0;
  511.    var dw = Math.acos((last_visible_character - 0.2) / last_visible_character);
  512.    var characters_counter = 0;
  513.    var characters = 0;
  514.    var characters_basis = last_visible_character;
  515.    var characters_div = 0;
  516.    if(last_visible_character > arg3)
  517.    {
  518.       var characters = Math.round(last_visible_character * Math.sin(dw));
  519.       while(characters_counter < last_visible_character - arg3)
  520.       {
  521.          txt_array.push(txt.substring(characters_counter,characters_counter + characters));
  522.          characters_counter += characters;
  523.       }
  524.       characters_basis = last_visible_character - characters_counter;
  525.       characters_div = characters_counter;
  526.       dw = Math.acos((characters_basis - 0.2) / characters_basis);
  527.    }
  528.    var w = dw;
  529.    while(w <= 1.5707963267948966)
  530.    {
  531.       characters = Math.round(characters_div + characters_basis * Math.sin(w));
  532.       if(characters <= characters_counter)
  533.       {
  534.          characters = characters_counter + 1;
  535.       }
  536.       if(characters >= last_visible_character)
  537.       {
  538.          characters = last_visible_character;
  539.          txt_array.push(txt.substring(characters_counter,characters));
  540.          break;
  541.       }
  542.       txt_array.push(txt.substring(characters_counter,characters));
  543.       characters_counter = characters;
  544.       w += dw;
  545.    }
  546.    temp_string = "";
  547.    var txtPfad = this;
  548.    var tw__interval = this.tw__interval = setInterval(function()
  549.    {
  550.       if(eval(txtPfad) == undefined)
  551.       {
  552.          clearInterval(tw__interval);
  553.       }
  554.       if(txt_array.length > 0)
  555.       {
  556.          temp_string += txt_array.shift();
  557.          txtPfad.text = temp_string + arg4;
  558.       }
  559.       else
  560.       {
  561.          clearInterval(tw__interval);
  562.          if(txtPfad.html)
  563.          {
  564.             txtPfad.htmlText = originalTxt;
  565.          }
  566.          else
  567.          {
  568.             txtPfad.text = originalTxt;
  569.          }
  570.          if(arg5)
  571.          {
  572.             txtPfad.styleSheet = arg5;
  573.          }
  574.          if(arg6)
  575.          {
  576.             arg6.apply(null,arg7);
  577.          }
  578.       }
  579.    }
  580.    ,arg2);
  581. };
  582. ASSetPropFlags(TextField.prototype,"typeWriter",1,0);
  583. TextField.prototype.stringCutter_advanced = function(arg1, arg2)
  584. {
  585.    var _loc8_ = this.textHeight;
  586.    if(arg1 == undefined)
  587.    {
  588.       arg1 = " ";
  589.    }
  590.    var _loc4_ = 0;
  591.    this.scroll = 1;
  592.    while(this.maxscroll > 1)
  593.    {
  594.       var _loc2_ = 0;
  595.       while(this.scroll <= 1 && _loc2_ < this.text.length)
  596.       {
  597.          _loc2_ = _loc2_ + 1;
  598.          Selection.setFocus(this);
  599.          this.scroll = 1;
  600.          Selection.setSelection(0,_loc2_);
  601.       }
  602.       var _loc5_ = this.text.lastIndexOf("\r",_loc2_ - _loc4_);
  603.       var _loc6_ = this.text.lastIndexOf(" ",_loc2_ - _loc4_);
  604.       var _loc3_ = Math.max(_loc5_,_loc6_);
  605.       if(_loc3_ == -1)
  606.       {
  607.          _loc3_ = _loc2_ - _loc4_ - arg1.length - 1;
  608.          break;
  609.       }
  610.       Selection.setFocus(this);
  611.       Selection.setSelection(_loc3_,this.length);
  612.       this.replaceSel(arg1);
  613.       this.scroll = 1;
  614.       _loc4_ += 2;
  615.    }
  616.    if(arg2)
  617.    {
  618.       this.styleSheet = arg2;
  619.    }
  620. };
  621. ASSetPropFlags(TextField.prototype,"stringCutter_advanced",1,0);
  622.